$(function(){
	/*获取 疾病列表 接口*/
	doctorList()
	function doctorList(){
		var param = {"pageNo":1,"pageSize":999,"isrecomm":1};
		function callBack(data){
			console.log(data);
			var html = "";
			for (i in data.diseaseList) {			
				html +='<li v='+data.diseaseList[i].disname+'><span>'+data.diseaseList[i].disname+'</span></li>'
			}
			$("#diseaseDataBody").append(html);
			
			var html2 = "";
			var json=data.doctorList;
			for (j in json) {	
				var $skilful =json[j].skilful;
				if(json[j].skilful==undefined){
					$skilful = " ";
				}
				html2 += '<li class="systemdoctor diseaseCls" v="'+json[j].id+'">'
					      	+'<div class="doctor-infor">'
								//+'<div class="ask-doctor" p="'+json[j].imprice+'" k="'+json[j].imisopen+'">问医生</div>'
								+'<div class="picture"><img src="'+json[j].avatar+'"></div>'
								+'<b>'+json[j].realname+'<span>'+json[j].deptName+'</span></b>'
								+'<br>'+json[j].doctortitle
								+'<br>'+json[j].hospitalName
								+'<p class="mui-ellipsis font1">擅长:'+$skilful+'</p>'
							+'</div>'	
							+'<div class="info font1"><div>服务患者端次数：<span>'+json[j].servicetimes+'</span></div><div>关注人数：<span>'+json[j].concernnumber+'</span></div></div></li>'
			}
			$(".choice-doctorList").append(html2);
			
			$("#doctorDataBody li").on("click",function(){
				var doctorId=$(this).attr("v");
				location.href = "../doctor/doctor-details.html?doctorid="+doctorId;
			});
			
			$("#doctorDataBody li .ask-doctor").on("click",function(event){
				event.stopPropagation()
				var result=checkUnfinishedOrder(USERID,$(this).parent().parent().attr("v"));
				if(result==true){
				   if($(this).attr("k")==0){
						mui.alert("该医生暂未开通图文咨询")
					}else{
						var consultOrder={};
						var doctorId = $(this).parent().parent().attr("v")
						consultOrder.doctorid= doctorId;
						consultOrder.payAmount=$(this).attr("p");
						consultOrder.orderDetail="图文咨询";
						consultOrder.orderType=1;
						var orderKey="doctor_index";
						 sessionStorage.setItem(orderKey,JSON.stringify(consultOrder));
						location.href = "../onlineContinuation/medication-consultation.html?doctorId="+doctorId;
					}
				}else{
					return false;
				}
			});
		}
		doctorModule.queryList(param,callBack);
	}
	
	$("#diseaseDataBody li").on("click",function(){
		var name= $(this).attr("v");
		name = escape(name);
		location.href = "../doctor/doctor-list.html?realname="+name;
		sessionStorage.setItem("doctorZz",JSON.stringify(1));
	})
	
	
	$(".searchBtn").on("click",function(){
		var value= $("#keyword").val();
		value = escape(value);
		if(value==""){
			mui.alert("请输入内容")
		}else{
			location.href = "../doctor/doctor-list.html?realname="+value;
			sessionStorage.setItem("doctorZz",JSON.stringify(2));
		}
	})
	
	
})
